package com.huawei.cloudservice;

import android.app.Activity;
import android.app.AlertDialog;
import android.content.Context;
import android.os.Bundle;
import android.text.TextUtils;
import com.huawei.hwid.api.common.e;
import com.huawei.hwid.api.common.o;
import com.huawei.hwid.core.constants.HwAccountConstants;
import com.huawei.hwid.core.datatype.HwAccount;
import com.huawei.hwid.core.datatype.UserInfo;
import com.huawei.hwid.core.helper.handler.ErrorStatus;

public class CloudAccount {
    private e a = null;

    public CloudAccount(e eVar) {
        this.a = eVar;
    }

    @Deprecated
    public HwAccount getAccountData() {
        if (this.a == null) {
            this.a = new e();
        }
        return this.a.b();
    }

    public String getAccountName() {
        return getAccountData().b();
    }

    public String getUserId() {
        return getAccountData().d();
    }

    public String getDeviceId() {
        return getAccountData().i();
    }

    public String getSubDeviceId() {
        return getAccountData().j();
    }

    public String getDeviceType() {
        return getAccountData().k();
    }

    public int getSiteId() {
        return getAccountData().e();
    }

    public String getServiceToken() {
        return getAccountData().g();
    }

    public String getAccountType() {
        return getAccountData().h();
    }

    public String getLoginUserName() {
        String l = getAccountData().l();
        if (TextUtils.isEmpty(l)) {
            return getAccountName();
        }
        return l;
    }

    public String getCountryCode() {
        return getAccountData().a();
    }

    public String getServiceCountryCode() {
        return getAccountData().n();
    }

    public String getStStatus() {
        return getAccountData().m();
    }

    public void serviceTokenAuth(Context context, String str, String str2, int i, CloudRequestHandler cloudRequestHandler) {
        this.a.a(context, str, str2, i, cloudRequestHandler);
    }

    @Deprecated
    public String getAuthToken() {
        return this.a.c();
    }

    @Deprecated
    public Bundle getAccountInfo() {
        return this.a.d();
    }

    @Deprecated
    public void logout(Context context) {
        this.a.e(context);
    }

    public void getUserInfo(Context context, String str, CloudRequestHandler cloudRequestHandler) {
        this.a.a(context, str, cloudRequestHandler);
    }

    public boolean updateUserInfo(Context context, UserInfo userInfo, CloudRequestHandler cloudRequestHandler) {
        return this.a.a(context, userInfo, cloudRequestHandler);
    }

    public boolean updateHeadPicture(Context context, String str, CloudRequestHandler cloudRequestHandler) {
        return this.a.b(context, str, cloudRequestHandler);
    }

    public AlertDialog getAccountManagerDialog(Activity activity, String str, Bundle bundle, CloudRequestHandler cloudRequestHandler) {
        if (activity == null || TextUtils.isEmpty(str) || cloudRequestHandler == null) {
            return null;
        }
        if (!o.b(activity)) {
            cloudRequestHandler.onError(new ErrorStatus(34, "hwid is not exit"));
            return null;
        } else if (!o.a((Context) activity, 20301000)) {
            return this.a.a(activity, str, bundle, cloudRequestHandler);
        } else {
            cloudRequestHandler.onError(new ErrorStatus(35, "hwid is low version"));
            return null;
        }
    }

    public void getRemoteAccessAuthorizeIntent(Context context, IntentResultHandler intentResultHandler) {
        this.a.a(context, HwAccountConstants.REMOTE_AUTH_INTENT, intentResultHandler);
    }

    public void getHomeCountryChangeIntent(Context context, IntentResultHandler intentResultHandler) {
        this.a.a(context, HwAccountConstants.HOME_COUNTRY_CHANGE_INTENT, intentResultHandler);
    }

    public void getRealNameVerifyIntent(Context context, int i, IntentResultHandler intentResultHandler) {
        this.a.a(context, i, intentResultHandler);
    }

    public void getRealNameInfo(Context context, CloudRequestHandler cloudRequestHandler) {
        this.a.c(context, cloudRequestHandler);
    }

    public void getAuthAppListIntent(Context context, IntentResultHandler intentResultHandler) {
        this.a.a(context, HwAccountConstants.AUTH_APP_LIST_INTENT, intentResultHandler);
    }
}
